import {createRouter, createWebHistory} from "vue-router"

import HomeView from "../views/HomeView.vue"
// import AboutView from "../views/AboutView.vue"


const routes = [
    {
        path: "/",               // 必填字段
        component: HomeView,     // 必填字段
        name: "home"             // 非必填字段，路由名字，建议加上
    },
    {
        path: "/about",
        // 通过懒加载方式注册组件
        component: () => import('../views/AboutView.vue'),
        name: "about",
        redirect: "/about/aboutus",
        children: [
            {
            // 注意：二级路径不要加 /
            path: "aboutus",
            name: "aboutus",
            component: () => import("../views/AboutSub/AboutUS.vue")
            },
            {
                // 注意：二级路径不要加 /
                path: "aboutinfo",
                name: "aboutinfo",
                component: () => import("../views/AboutSub/AboutInfo.vue")
                },
        ]
    },
    {
        path: "/news",
        // 通过懒加载方式注册组件
        component: () => import('../views/NewsView.vue'),
        name: "news"
    },
    {
        path: "/details/:name",
        // 通过懒加载方式注册组件
        component: () => import('../views/DetailsView.vue'),
        name: "newsdetails"
    },
]


const router = createRouter({
    // createWebHashHistory    这种路径里面会有井号 # 出现，
    // createWebHistory        此种方式需要后台做重定向，否则会出现404
    history: createWebHistory(),
    routes
})

export default router;